package com.lagou.Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import com.google.gson.Gson;
import com.lagou.biz.ManagerBiz;
import com.lagou.biz.impl.ManagerBizImpl;
import com.lagou.entity.Third;

/**
 * Servlet implementation class AServlet
 */
@WebServlet("/ManagerSecondServlet")
public class ManagerSecondServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
   
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out=response.getWriter();
		ManagerBiz biz=new ManagerBizImpl();
		List<Third> tlist=new ArrayList<Third>();
		tlist=biz.queryAllThird();
		List<Third> tlist2=new ArrayList<Third>();
		int myfrom=Integer.valueOf(request.getParameter("myfrom"));
		for(Third t:tlist) {
			if(t.getSid()==myfrom) {
				tlist2.add(t);
			}
		}
		Gson gson=new  Gson();
		String str=gson.toJson(tlist2);
		out.print(str);
		out.flush();
		out.close();
		
		
		
		
		
		
	}

}
